package cwb1;

import java.util.Map;

import com.google.appengine.api.datastore.EntityNotFoundException;

/**
 * This class creates new activities depending on the activityType. It is generally used by the DataEngine. After collecting the 
 * right properties, the DataEngine must recreate the right activity. Their are some public fields, used as flags for the 
 * subclasses of activity.
 * 
 * @author Aurora
 *
 */
public class ActivityFactory {
	
	//College flag.
	public final static long COLLEGE = 1;
	//Job flag.
	public final static long JOB = 2;
	//Nightlife flag.
	public final static long NIGHTLIFE = 3;
	//Practice flag.
	public final static long PRACTICE = 4;
	//Sleep flag.
	public final static long SLEEP = 5;
	//Sport flag.
	public final static long SPORT = 6;
	//Study flag.
	public final static long STUDY = 7;
	
	/**
	 * The constructor is private. You are not allowed to make an object of this class.
	 */
	private ActivityFactory()
	{
		
	}
	
	/**
	 * Creates the right type of activity, using a Map with the properties.
	 * 
	 * @param properties The properties of the kind of activity.
	 * @return The right kind of activity corresponding the type of the given activity.
	 */
	public static Activity createActivity(Map<String,Object> properties) {
		Activity activity = null;
		if(properties.get("activityType").equals(COLLEGE)) {
			College college = new College(properties);
			activity = college;
		}
		
		else if(properties.get("activityType").equals(JOB)) {
			Job job = new Job(properties);
			activity = job;
		}
		
		else if(properties.get("activityType").equals(NIGHTLIFE)) {
			Nightlife nightlife = new Nightlife(properties);
			activity = nightlife;
		}
		
		else if(properties.get("activityType").equals(PRACTICE)) {
			Practice practice = new Practice(properties);
			activity = practice;
		}
		
		else if(properties.get("activityType").equals(SLEEP)) {
			Sleep sleep = new Sleep(properties);
			activity = sleep;
		}
		
		else if(properties.get("activityType").equals(SPORT)) {
			Sport sport = new Sport(properties);
			activity = sport;
		}

		else if(properties.get("activityType").equals(STUDY)) {
			Study study = new Study(properties);
			activity = study;
		}

		return activity;
		
	}
}
